100 CLS:PRINT "COUNT THE NUMBER OF WORDS IN A DOCUMENT -":PRINT
110 LINE INPUT "ENTER FILE NAME INCLUDING EXTENSION: ";F$:PRINT
120 IF F$="" THEN END
130 ON ERROR GOTO 310
140 OPEN F$ FOR INPUT AS #1
150 ON ERROR GOTO 0
160 CLS:PRINT "HIT ESCAPE TO QUIT WHILE IN PROGRESS":PRINT:PRINT:PRINT
170 NUM=0
180 IF EOF(1) THEN CLOSE:PRINT:PRINT "TOTAL NUMBER OF WORDS IN DOCUMENT =";NUM:END
190 LINE INPUT#1,I$
200 PRINT I$
210 IF I$="" THEN GOTO 180
220 S=0
230 FOR C=1 TO LEN(I$)
240 IF MID$(I$,C,1)=" " THEN S=S+1
250 NEXT C
260 NUM=NUM+S+1
270 IN$=INKEY$:IF IN$="" THEN 180
280 IF IN$=CHR$(27) THEN CLOSE:PRINT:PRINT "TERMINATED - NUMBER OF WORDS UP TO THIS POINT =";NUM:END
290 GOTO 180
300 REM -----
310 RESUME 320
320 PRINT:PRINT "FILE NOT FOUND":END

